# -*- codeing = utf-8 -*-
# @Time : 2021/2/28 10:24
# @Atuthor: 朱朱
# @File: 152高级装饰器.py
# @Software: PyCharm

def can_play(clock): # 在装饰器外面,再加一层函数 ,给装饰器添加参数
    print('最外层函数被调用了,clock={}'.format(clock))

    def handle_action(fn):
        print('handle_action,被调用了')

        def do_action(name,game):
            if clock < 21:
                fn(name,game)
            else:
                print('太晚了,不能玩游戏了....')
        return do_action
    return handle_action
@can_play(12) # 给装饰器添加参数,用装饰器来判断,什么时候需要装饰.
def play_game(name,game):
    print(name+'正在玩游戏...'+game)

play_game('jack','hero.')